*************************************************************************************
*** Replication: Tepe, Markus and Ekaterina Widmer-Lytkina. 2026.                 ***
*** Populist Attitudes Among Civil Servants. A Source of Liberal Robustness?      ***
*** International Review of Administrative Sciences.                              ***
*************************************************************************************

* Cross-National Evidence: Comparing 16 Democratic States

****************************************************************************************
*** Load data
****************************************************************************************

* Download this version via: https://cses.org/data-download/download-data-documentation/
* CSES-MODULE-5
* VER2023-JUL-25
* doi:10.7804/cses.module5.2023-07-25

use "~\cses5.dta" , replace 
cd "~"
save data.dta, replace

****************************************************************************************
*** Recode Variables
****************************************************************************************

*** Country ID v1
encode E1006_UNALPHA2, gen(cr)

*** Countries
gen cr_core = 0
replace cr_core = 1 if E1006_NAM=="Finland"
replace cr_core = 1 if E1006_NAM=="Denmark"
replace cr_core = 1 if E1006_NAM=="Norway"
replace cr_core = 1 if E1006_NAM=="Austria"
replace cr_core = 1 if E1006_NAM=="Germany"
replace cr_core = 1 if E1006_NAM=="Switzerland"
replace cr_core = 1 if E1006_NAM=="France"
replace cr_core = 1 if E1006_NAM=="Portugal"
replace cr_core = 1 if E1006_NAM=="Italy"
replace cr_core = 1 if E1006_NAM=="Canada"
replace cr_core = 1 if E1006_NAM=="United States of America"
replace cr_core = 1 if E1006_NAM=="Great Britain"
replace cr_core = 1 if E1006_NAM=="Poland"
replace cr_core = 1 if E1006_NAM=="Hungary"
replace cr_core = 1 if E1006_NAM=="Brazil"
replace cr_core = 1 if E1006_NAM=="Mexico"


*** Anti-Elitist Attitudes
recode E3004_1 1=5 2=4 3=3 4=2 5=1  7=. 8=. 9=.
recode E3004_2 1=5 2=4 3=3 4=2 5=1  7=. 8=. 9=.
recode E3004_3                      7=. 8=. 9=.
recode E3004_4 1=5 2=4 3=3 4=2 5=1  7=. 8=. 9=.
recode E3004_5 1=5 2=4 3=3 4=2 5=1  7=. 8=. 9=.
recode E3004_6 1=5 2=4 3=3 4=2 5=1  7=. 8=. 9=.
recode E3004_7 1=5 2=4 3=3 4=2 5=1  7=. 8=. 9=.

*** Anti-Elitist Attitudes Alpha
alpha E3004_1 E3004_2 E3004_3 E3004_4 E3004_5 E3004_6 E3004_7

*** Anti-Elitist Attitudes (Index and Factor Score)
gen pop1 = (E3004_1+ E3004_2 +E3004_3 +E3004_4 +E3004_5 +E3004_6 +E3004_7)/7
factor E3004_1 E3004_2 E3004_3 E3004_4 E3004_5 E3004_6 E3004_7, pcf
predict pop2

*** Public Employment
recode E2009 1=1 2=0 else=., gen(pub)
label define publb 0 "Private Sector" 1 "Public Sector"
label values pub publb
recode E2009 1=1 2=2 4=3 else=., gen(pub3)
label define publb3 1 "Public Sector" 2 "Privte Sector" 3 "Non-Profit Sector"
label values pub3 publb3

*** Age
gen age = E2001_A
replace age = . if E2001_A==9997
replace age = . if E2001_A==9999

*** Gender
recode E2002 1=0 2=1 else=., gen(fem)

*** Left Right
gen lr = E3020
replace lr = . if E3020>10

*** Education
recode E2003 1=1 2=2 3=3 4=4 5=5 6=6 7=7 8=8 9=9 96=1 97=. 98=. 99=., gen(isced)

*** ID
gen id = E1005
tabulate cr pub

* Strong leader
tab E3004_5
gen E3004_5_scale = E3004_5/5

*** Reduce Sample 
keep if cr_core==1

*** Country ID v1
encode E1006_UNALPHA3, gen(cr2)
drop if !inlist(cr2,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16)
drop if pub==. 

gen cr_sort = .
replace cr_sort = 5  if cr == 2   
replace cr_sort = 3  if cr == 6   
replace cr_sort = 6  if cr == 7   
replace cr_sort = 4  if cr == 11 
replace cr_sort = 10 if cr == 12  
replace cr_sort = 12 if cr == 13  
replace cr_sort = 7  if cr == 14  
replace cr_sort = 2  if cr == 15  
replace cr_sort = 14 if cr == 18  
replace cr_sort = 8  if cr == 23  
replace cr_sort = 11 if cr == 31  
replace cr_sort = 13 if cr == 34  
replace cr_sort = 9  if cr == 35  
replace cr_sort = 1  if cr == 44  
replace cr_sort = 15 if cr == 5 
replace cr_sort = 16 if cr == 29 

label define cr_sort_lbl ///
    5  "AT" ///
    3  "CA" ///
    6  "CH" ///
    4  "DE" ///
    10 "DK" ///
    12 "FI" ///
    7  "FR" ///
    2  "GB" ///
    14 "HU" ///
    8  "IT" ///
    11 "NO" ///
    13 "PL" ///
    9  "PT" ///
    1  "US" ///
	15 "BR" ///
	16 "MX"
label values cr_sort cr_sort_lbl


****************************************************************************************
*** Analysis
****************************************************************************************

*****************
*** Figure 4 ****
*****************

*** Anti-Elitist (index)
reg pop1 i.pub##i.cr_sort age fem isced lr E3011, cluster(id)
margins pub, at(cr_sort=(1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16))
mplotoffset, offset(0.25) recast(scatter) ytitle("Predictive Margins (with 95% CIs)") xtitle(" ") title(" ") legend(pos(6) cols(2))
graph save Figure_4.gph, replace

*** Anti-Elitist (factor score)
reg pop2 i.pub##i.cr_sort age fem isced lr  E3011, cluster(id)
margins pub, at(cr_sort=(1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16))
mplotoffset, offset(0.25) recast(scatter) ytitle("Predictive Margins (with 95% CIs)") xtitle(" ") title(" ") legend(pos(6) cols(2))


***************************
*** Appendix Figure B1 ****
***************************

* Anti-Elitist (Strong Leader)
reg E3004_5_scale i.pub##i.cr_sort age fem isced lr  E3011, cluster(id)
margins pub, at(cr_sort=(1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16))
mplotoffset, offset(0.25) recast(scatter) ytitle("Predictive Margins (with 95% CIs)") xtitle(" ") title(" ") legend(pos(6) cols(2))
graph save Appendix_Figure_B1.gph, replace

**************************
*** Appendix Table B4 ****
**************************

reg pop1 i.pub  i.cr_sort age fem isced lr  E3011, cluster(id)
est store m1
reg pop1 i.pub##i.cr_sort age fem isced lr  E3011, cluster(id)
est store m2
esttab m1 m2 using Appendix_Table_B4.csv, r2 se brackets star(* 0.10 ** 0.05 *** 0.01) label nogaps  replace 


**************************
*** Appendix Table B3 ****
**************************

tabstat pop1 pub age fem isced lr  E3011 , by(cr_sort) stats(n mean)





